package com.lzt.admin.common.handler;

import com.lzt.admin.common.utils.PrintResponseUtil;
import com.lzt.admin.common.vo.UserDetailsVO;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;
@Component
@RequiredArgsConstructor
public class LztAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
    private final PrintResponseUtil printResponseUtil;
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        UserDetailsVO user = (UserDetailsVO) authentication.getPrincipal();
        printResponseUtil.printSuccess(request,response,user);
    }
}
